package com.example.tellwin;

import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.os.Bundle;

import com.example.tellwin.base.CpBaseActivty;
import com.example.tellwin.common.Common;

import org.song.videoplayer.DemoQSVideoView;
import org.song.videoplayer.QSVideo;
import org.song.videoplayer.media.AndroidMedia;
import org.song.videoplayer.media.BaseMedia;

import butterknife.BindView;
import butterknife.ButterKnife;

public class MediaActivity extends CpBaseActivty {

    @BindView(R.id.qs)
    DemoQSVideoView qs;

    String url;
    Class<? extends BaseMedia> decodeMedia;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_media);
        ButterKnife.bind(this);
        initViews();
        initEvents();
        initDatas();
    }

    @Override
    protected void initViews() {
//进入全屏的模式 0横屏 1竖屏 2传感器自动横竖屏 3根据视频比例自动确定横竖屏      -1什么都不做
        qs.enterFullMode = 1;
        //是否非全屏下也可以手势调节进度
        qs.isWindowGesture = false;
    }

    @Override
    protected void initEvents() {

    }

    @Override
    protected void initDatas() {
        String url = getIntent().getStringExtra(Common.MEDIA_PATH);
        qs.release();
        qs.setDecodeMedia(AndroidMedia.class);
        qs.setUp(QSVideo.Build(url).title("").definition("").resolution("").build());
        if(url.contains("http")) {
            qs.openCache();//缓存配置见最后,缓存框架可能会出错,
        }
        qs.play();

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        qs.release();
    }
}
